#ifndef __ADPM_FS_H__
#define __ADPM_FS_H__

#include "tools.h"
#include "server.h"
#include "types.h"
#include <linux/types.h>
#include <linux/delay.h>

#define ADPM_FTAB_BIT 7
//元数据起始位置
extern struct adpm_page *adpm_map;
//记录有多少挂载点
extern atomic_t adpm_nr_mp;

extern spinlock_t adpm_ftab_lock;
extern struct hlist_head adpm_ftab[1<<ADPM_FTAB_BIT];

int adpm_fill_super(struct super_block *sb, void *data, int silent);
void adpm_clear_ftab(void);

struct adpm_client_file *adpm_find_file(char *name);
void adpm_del_file(char *name);

// enter the function with rbtree locked
struct adpm_page *adpm_insert_one_data_page(struct adpm_client_file *f, long pgoff, bool no_swap);
// enter the function with rbtree locked
struct adpm_page *adpm_file_find_page(struct adpm_client_file *f, long vmpgoff);
// enter the function with rbtree locked
void adpm_file_insert_dirty(struct adpm_client_file *f, struct adpm_dirty *di);

#endif
